<%--
  Created by IntelliJ IDEA.
  User: 杨威
  Date: 2021/9/23
  Time: 19:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-1.12.4.js"></script>
</head>
<body>
<h2>您的用户名：<span id="username"></span></h2>
<h2>您的密码为：<span id="password"></span></h2>
<button onclick="getJson()">获取数据</button>
<script type="text/javascript">
    function getJson() {
        $.ajax({
            url:"testJson",
            type:"post",
            // contentType:"application/json;charset=utf-8",
            dataType:"json",
            success:function (user) {
                $("#username").text(user.username)
                $("#password").text(user.password)
            }
        })
    }
</script>
</body>
</html>
